//
//  EmoticonViewCell.swift
//  表情键盘
//
//  Created by 耐克了解了 on 12/4/17.
//  Copyright © 2017年 耐克了解了. All rights reserved.
//

import UIKit

class EmoticonViewCell: UICollectionViewCell {
    
    //MARK: -懒加载属性
    fileprivate lazy var emoticonBtn : UIButton = UIButton()
    
    var emoticonModel : Emoticon?{
        didSet{
            guard let emoticonModel = emoticonModel else {
                return
            }
           
            //设置emoticonBtn的内容
            emoticonBtn.setImage( UIImage(contentsOfFile: emoticonModel.pngPath ?? ""), for: .normal)
            emoticonBtn.setTitle(emoticonModel.emoticonCode, for: .normal)
            
            //设置删除按钮
            if emoticonModel.isRemove {
                emoticonBtn.setImage(UIImage(named:"compose_emotion_delete"), for: .normal)
            }
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

}

//MARK: - 设置UI
extension EmoticonViewCell{
    
    fileprivate func setupUI(){
        
        contentView .addSubview(emoticonBtn)
    
        //设置btn的frame
        emoticonBtn.frame = contentView.bounds
        
        //设置btn的属性
        emoticonBtn.isUserInteractionEnabled = false
        
        emoticonBtn.titleLabel?.font = UIFont.systemFont(ofSize: 30)
        
    }
    
}
